namespace MyBlog.Model
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel.DataAnnotations;
    using System.ComponentModel.DataAnnotations.Schema;

    [Serializable]
    public partial class MoodModel
    {
        public MoodModel()
        {
            MoodCommentModels = new List<MoodCommentModel>();
        }

        public int ID { get; set; }

        [Required]
        [StringLength(50)]
        public string AccountId { get; set; }

        [Required]
        [StringLength(550)]
        public string Content { get; set; }

        public DateTime CreateTime { get; set; }

        public DateTime LastUpdateTime { get; set; }

        public string AgreeUsers { get; set; }

        public int AgreeCount
        {
            get
            {
                if (!string.IsNullOrWhiteSpace(AgreeUsers))
                {
                    if (AgreeUsers.Contains("&"))
                    {
                        return AgreeUsers.Split(new char[] { '&' }, StringSplitOptions.RemoveEmptyEntries).Length;
                    }
                    return 1;
                }
                return 0;
            }
        }

        public AccountModel Account { get; set; }

        public List<MoodCommentModel> MoodCommentModels { get; set; }
    }
}
